home *** CD-ROM | disk | FTP | other *** search
- Path: news.nyu.edu!schonberg!dewar
- From: dewar@cs.nyu.edu (Robert Dewar)
- Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu
- Subject: Re: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada)
- Date: 8 Apr 1996 21:13:48 -0400
- Organization: Courant Institute of Mathematical Sciences
- Message-ID: <dewar.829012027@schonberg>
- References: <JSA.96Feb16135027@organon.com> <dewar.828757752@schonberg> <danpop.828819479@rscernix> <dewar.828879781@schonberg> <4k9qhe$65r@solutions.solon.com> <dewar.828936837@schonberg> <828964950snz@genesis.demon.co.uk> <4kbfup$2vd@news1.mnsinc.com> <4kbl5i$p3@mordred.gatech.edu> <4kbr5q$j1l@mulga.cs.mu.OZ.AU>
- NNTP-Posting-Host: schonberg.cs.nyu.edu
- X-Newsreader: NN version 6.5.0 (NOV)
-
- Fergus says
-
- "Nope, you've got cause and effect backwards. There's no way to make
- undefined behavior portable *because* it is undefined. If a language
- has constructs with undefined behaviour, this will lead to portability
- problems. But some languages have fewer areas of undefined behaviour
- than others. Some languages don't have any undefined behaviour at
- all."
-
- True enough, but this is only achievable by going to a fairly high
- level of abstraction. For example SNOBOL4 (or SPITBOL) programs
- are totally portable, with no undefined behavior at all.
-
- But if you have a language that can twiddle bits at a low level, it is
- hard to see how undefined behavior could be eliminated completely.
-
- It is definitely true that constructs with undefined (or non-deterministic)
- behavior, can lead to portability problems. Remember portable programs
- are portable by definition -- it's possible to write portable programs
- in any language. Portability problems are precisely caused by constructs
- that render progams non-portable. This is obvious, but worth saying,
- because for example Peter tends to say "What portability problems,
- your code is just wrong :-)"
-
- Back to non-determinism. A language can have totally defined semantics
- and still have non-deterministic semantics. For example in SETL, a language
- with no undefined semantics:
-
- x := arb {1,2,3,4};
-
- selects an arbitrary element of the set, and puts any of 1,2,3,4 in X.
- The semantics of SETL is well defined (although as usual the presence
- of such non-determinism complicates the formal semantics). However,
- it is now possible to write non-portable SETL programs that incorrectly
- depend on "knowing" that in practice the compiler in use always implements
- arb by selecting the minimum element (a perfectly correct implementation,
- arb does not mean random!).
-
- A similar case arises in Ada with the select statement, which is free
- to select any open alternative non-determinisitically, or with the
- semantics of expression evaluation, where it is non-determinstic
- whether the right or left operand of an operator is evaluated first.
- The second case could be eliminated from the language, but anyting
- invollving timing is likely to lead to some non-eliminatable
- non-determinism.
- dp
-
-